package com.example.demo.demo;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.MathContext;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @Description
 * @Author
 * @Date 2020/3/30 19:00
 **/
public class BinaryTest {
    public static void main(String[] args) {
//        BigInteger bigInteger = new BigInteger("29");
//        BigInteger bigInteger1 = new BigInteger("1010", 3);
//        BigInteger bigInteger2 = BigInteger.valueOf(331);
//
//        System.out.println(bigInteger.toString());
//        System.out.println(bigInteger1.toString());
//        System.out.println(bigInteger2.toString(2));
        final BigDecimal bigDecimal = BigDecimal.valueOf(0.3);

        final BigDecimal bigDecimal1 = BigDecimal.valueOf(0.1);
        BigDecimal divide = bigDecimal1.divide(bigDecimal,new MathContext(5, RoundingMode.HALF_UP));
    }

    private static void binary() {
        List<String> strings = new ArrayList<>();
        strings.add("");
        strings.subList(0, 1);
        int bin = 0b1100010;
        int oct =0142;
        int hex =0X62;
        int dec = 98;

        //前缀是数字0,不是字母O;
        //英文字母b x不区分大小写
        //在指定进制中使用规定的代码
        //底层存储都是二进制形式
        //java默认显示是十进制数

        System.out.println("2:"+bin);
        System.out.println("8:"+oct);
        System.out.println("16:"+hex);
        System.out.println("10:"+dec);
        //上面的输出结果都是98
        System.out.println(Integer.toBinaryString(bin));
        System.out.println(Integer.toOctalString(oct));
        System.out.println(Integer.toHexString(hex));
        System.out.println("10:"+dec);

        System.out.println(Integer.toString(98,2));
        System.out.println(Integer.toString(98,8));
        System.out.println(Integer.toString(98,16));

        System.out.println(Integer.parseInt("98",2));
        System.out.println(Integer.valueOf("98",2));
    }
}
